<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @promotion } %>
<div class="row">
  <div id="general_fields" class="col-xs-9">
    <div class="row">
      <div class="col-xs-3">
        <%= f.field_container :name do %>
          <%= f.label :name %>
          <%= f.text_field :name, :class => 'fullwidth' %>
        <% end %>

        <%= fields_for :promotion_builder do |bf| %>
          <%= bf.field_container :base_code do %>
            <%= bf.label :base_code %>
            <%= bf.text_field :base_code, :readonly => !@promotion.new_record?, :class => 'fullwidth' %>
          <% end %>

          <%= bf.field_container :number_of_codes do %>
            <%= bf.label :number_of_codes %>
            <%= bf.text_field :number_of_codes, :readonly => !@promotion.new_record?, class: 'fullwidth' %>
          <% end %>
        <% end %>

        <%= f.field_container :per_code_usage_limit do %>
          <%= f.label :per_code_usage_limit %>
          <%= f.text_field :per_code_usage_limit, class: 'fullwidth' %>
        <% end %>

        <%= f.field_container :path do %>
          <%= f.label :path %>
          <%= f.text_field :path, :class => 'fullwidth' %>
        <% end %>

        <%= f.field_container :advertise do %>
          <%= f.check_box :advertise %>
          <%= f.label :advertise %>
        <% end %>

        <%= f.field_container :apply_automatically do %>
          <%= f.check_box :apply_automatically %>
          <%= f.label :apply_automatically %>
        <% end %>
      </div>

      <div class="col-xs-9">
        <%= f.field_container :description do %>
          <%= f.label :description %><br />
          <%= f.text_area :description, :rows => 7, :class => 'fullwidth' %>
        <% end %>

        <%= f.field_container :category do %>
          <%= f.label :promotion_category_id, Spree::PromotionCategory.model_name.human %><br />
          <%= f.collection_select(:promotion_category_id, @promotion_categories, :id, :name, { :include_blank => Spree.t('match_choices.none') }, { :class => 'select2 fullwidth' }) %>
        <% end %>
      </div>
    </div>
  </div>

  <div id="expiry_fields" class="col-xs-3">
    <%= f.field_container :overall_usage_limit do %>
      <%= f.label :usage_limit %><br />
      <%= f.number_field :usage_limit, :min => 0, :class => 'fullwidth' %><br>
      <span class="info">
        <%= Spree.t(:current_promotion_usage, :count => @promotion.usage_count) %>
      </span>
    <% end %>

    <div id="starts_at_field" class="field">
      <%= f.label :starts_at %>
      <%= f.text_field :starts_at, :value => datepicker_field_value(@promotion.starts_at), :class => 'datepicker datepicker-from fullwidth' %>
    </div>

    <div id="expires_at_field" class="field">
      <%= f.label :expires_at %>
      <%= f.text_field :expires_at, :value => datepicker_field_value(@promotion.expires_at), :class => 'datepicker datepicker-to fullwidth' %>
    </div>
  </div>
</div>
